package com.xingkeduo.dto.transter.activitystorelist;

import java.math.BigDecimal;

import com.alibaba.fastjson.JSONObject;

import lombok.Data;

@Data
public class Activity_Store_list {

	private String activity_id; // 活动id
	private String activity_amount; // 活动面额
	private String is_overlying; // 是否与优惠权益同享
	private String activity_type; // 优惠类型 0 立减，1 折扣，2 特价,3免费
	private String activity_name;// //活动名称
	private String short_desc;// 立减5元 优惠方式+活动面额
	private String unusable_reason;// 当前活动最低消费金额为100元 //不可用描述

	public void covert(JSONObject json) {
		this.activity_id = json.getOrDefault("id", "")==null?"":json.getOrDefault("id", "").toString();
		this.activity_amount =  json.getOrDefault("activityAmount", "")==null?"":json.getOrDefault("activityAmount", "").toString();
		this.is_overlying = json.getOrDefault("isOverlying", "")==null?"":json.getOrDefault("isOverlying", "").toString();
		this.activity_type = json.getOrDefault("preferentialMode", "")==null?"":json.getOrDefault("preferentialMode", "").toString();
		this.activity_name = json.getOrDefault("name", "")==null?"":json.getOrDefault("name", "").toString();
		this.unusable_reason = json.getOrDefault("unusableReason", "")==null?"":json.getOrDefault("unusableReason", "").toString();
		if("0".equalsIgnoreCase(activity_type)) {
			this.short_desc = "立减"+activity_amount+"元";
		}
		if("1".equalsIgnoreCase(activity_type)) {
			BigDecimal activityAmount = new BigDecimal(activity_amount).multiply(BigDecimal.valueOf(10)).setScale(1, BigDecimal.ROUND_HALF_UP);
			this.short_desc = "折扣"+activityAmount.toString()+"折";
		}
		if("2".equalsIgnoreCase(activity_type)) {
			this.short_desc = "特价"+activity_amount+"元";
		}
		if("3".equalsIgnoreCase(activity_type)) {
			this.short_desc = "免费";
		}
		String mode = json.getOrDefault("activityType", "")==null?"":json.getOrDefault("activityType", "").toString();
		if("BYPASS_FLOW".equals(mode)) {
			this.short_desc = "分时段立减";
		}
	}

}
